package hn.cch.web.request.controller;

import hn.cch.web.request.entity.ValidateEntity;
import hn.cch.web.request.validate.ValidatePost;
import hn.cch.web.request.validate.ValidatePut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping(value = "/validate")
@RestController()
public class ValidateController {

    private static final Logger logger = LoggerFactory.getLogger(ValidateController.class);


    @RequestMapping(value = "/get", method = RequestMethod.GET)
    public ResponseEntity<String> get() {
        logger.info("get");
        return ResponseEntity.ok("OK");
    }


    @RequestMapping(value = "/post", method = RequestMethod.POST)
    public ResponseEntity<String> post(@RequestBody @Validated(value = {ValidatePost.class}) ValidateEntity validateEntity) {
        logger.info("post");
        return ResponseEntity.ok("OK");
    }

    @RequestMapping(value = "/put", method = RequestMethod.PUT)
    public ResponseEntity<String> put(@RequestBody @Validated(value = {ValidatePut.class}) ValidateEntity validateEntity) {
        logger.info("put");
        return ResponseEntity.ok("OK");
    }


}
